<?PHP
include("../config/connect.php");
include("../public/common.php");

$id = CheckUrlParamNoDie("id");
$user_type = CheckUrlParamNoDie("type");
$nPage = CheckUrlParamNoDie("page");

if($nPage == "")
	$nPage = 0;
	
if( $id == "" )
{
	echo "error";
	exit;
}

$count = mysql_num_rows(mysql_query("select id from recommend_fee where user_id=$id"));

$PAGE_SIZE = 6;
$limit = " limit ". $nPage*$PAGE_SIZE .",$PAGE_SIZE";
$sql = "select month(time) as m,under_users,all_under_users,fee,state from recommend_fee where user_id=$id order by time desc".$limit;

$result = mysql_query( $sql );
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	font-size: 12px;
	color: #000;
	font-family: 宋体;
}
</style>
</head>

<body style="margin-left:0; margin-top:0; margin-right:0; margin-bottom:0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
      <tr bgcolor="#F4D662">
        <td width="145" height="24" align="center"><strong>月份</strong></td>
        <td width="263" align="center"><strong>共推荐人数</strong></td>
        <td width="283" align="center"><strong>本月有购物行为人数</strong></td>
        <td width="315" align="center"><strong>奖励</strong></td>
        <td width="213" align="center"><strong>状态</strong></td>
  </tr>
      <?PHP 
	  $i = $PAGE_SIZE * $nPage + 1;
	  if ( $count > 0 ) 
	  {
	  while( $result && $row = mysql_fetch_assoc( $result )) {
	  ?>
      <tr bgcolor="<?PHP if ($i % 2 == 0) echo "#EAE7BB"; else echo "#EEEEEE" ?>">
        <td height="24" align="center"><?PHP if ($row["m"] == 1) echo "12"; else echo $row["m"] - 1; ?>月</td>
        <td align="center"><?PHP echo $row["all_under_users"]; ?></td>
        <td align="center"><?PHP echo $row["under_users"]; ?></td>
        <td align="center"><?PHP echo round($row["fee"],2); ?>元</td>
        <td align="center">
        <?PHP 
		if ($row["state"] == 1)
			echo "<img src='images/accept.gif' />&nbsp;已发放";
		else
			echo "<img src='images/clock.gif' />&nbsp;未发放";
		?>
        </td>
      </tr>
      <?PHP
	  $i++;
		}
	}	// if
	else
	{
		echo "<tr><td align='center'>暂时没有数据</td></tr>";
	}
		?>
</table>

<div>
<table width="100%" cellspacing="4">
  <tr>
<td>
<?PHP
if ($user_type == "N")
	echo "&nbsp;亲爱的用户，加入购物兔联盟后，才能拿到这笔推广费哦，详情请参见：<a href='http://gouwutu.com/union?ref=myserver' target='_blank'>联盟首页</a>";
else
	echo "&nbsp;亲爱的联盟用户，邀请您的朋友加入购物兔联盟，他推荐的用户，您也能得到收益哦，详情请参见：<a href='http://gouwutu.com/union?ref=myserver' target='_blank'>联盟首页</a>";
?>
</td>

<td align="right">
<?PHP if ($count > $PAGE_SIZE) {?>
<a href="?page=0<?PHP echo "&id=$id&type=$user_type"; ?>">首页</a>&nbsp;&nbsp;
<?PHP if ($nPage > 0) {?>
<a href="?page=<?PHP echo $nPage-1; ?><?PHP echo "&id=$id&type=$user_type"; ?>">上一页</a>&nbsp;&nbsp;
<?PHP } ?>
<?PHP if ($nPage < intval($count / $PAGE_SIZE)) {?>
<a href="?page=<?PHP echo $nPage+1; ?><?PHP echo "&id=$id&type=$user_type"; ?>">下一页</a>&nbsp;&nbsp;
<?PHP } ?>
<a href="?page=<?PHP echo intval($count / $PAGE_SIZE); ?><?PHP echo "&id=$id&type=$user_type"; ?>">尾页</a>&nbsp;&nbsp;
<?PHP } ?>
</td>

</tr></table>
</div>

</body>
</html>

